#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 50005;

int n, m;
struct Node {
  int cnt;
  int left, right, mx, tag;  // tag:-1 init, 0 empty, 1 full
} tr[N << 2];
Node merge(Node l, Node r) {
  Node res;
  res.cnt = l.cnt + r.cnt;
  res.left = l.left + (l.cnt == 0 ? r.left : 0);
  res.right = r.right + (r.cnt == 0 ? l.right : 0);
  res.mx = max({l.mx, r.mx, l.right + r.left});
  res.tag = -1;
  return res;
}
void pushup(int p) { tr[p] = merge(tr[p << 1], tr[p << 1 | 1]); }
void build(int p, int l, int r) {
  tr[p].tag = -1;
  if (l == r) {
    tr[p].cnt = 0;
    tr[p].left = tr[p].right = tr[p].mx = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(p << 1, l, mid);
  build(p << 1 | 1, mid + 1, r);
  pushup(p);
}
void addtag(int d, int p, int l, int r) {
  tr[p].tag = d;
  int len = r + 1 - l;
  tr[p].cnt = tr[p].tag * len;
  tr[p].left = tr[p].right = tr[p].mx = (1 - tr[p].tag) * len;
}
void pushdown(int p, int l, int r) {
  if (tr[p].tag != -1) {
    int mid = (l + r) >> 1;
    addtag(tr[p].tag, p << 1, l, mid);
    addtag(tr[p].tag, p << 1 | 1, mid + 1, r);
    tr[p].tag = -1;
  }
}
void update(int L, int R, int d, int p, int l, int r) {
  if (L <= l && R >= r) {
    addtag(d, p, l, r);
    return;
  }
  pushdown(p, l, r);
  int mid = (l + r) >> 1;
  if (L <= mid) update(L, R, d, p << 1, l, mid);
  if (R > mid) update(L, R, d, p << 1 | 1, mid + 1, r);
  pushup(p);
}
Node query(int L, int R, int p, int l, int r) {
  if (L <= l && R >= r) return tr[p];
  pushdown(p, l, r);
  int mid = (l + r) >> 1;
  if (R <= mid)
    return query(L, R, p << 1, l, mid);
  else if (L > mid)
    return query(L, R, p << 1 | 1, mid + 1, r);
  else {
    Node x = query(L, R, p << 1, l, mid);
    Node y = query(L, R, p << 1 | 1, mid + 1, r);
    return merge(x, y);
  }
}
int query(int d) {
  int l = 1, r = n;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (query(1, mid, 1, 1, n).mx >= d)
      r = mid - 1;
    else
      l = mid + 1;
  }
  if (l > n) return 0;
  return l + 1 - d;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  build(1, 1, n);
  while (m--) {
    int op, x, y;
    cin >> op >> x;
    if (op == 1) {
      y = x;
      x = query(y);
      if (x == 0) {
        cout << 0 << endl;
      } else {
        update(x, x + y - 1, 1, 1, 1, n);
        cout << x << endl;
      }
    } else {
      cin >> y;
      update(x, x + y - 1, 0, 1, 1, n);
    }
  }
  return 0;
}